package com.ruoyi.web.foreigncurrency.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.foreigncurrency.domain.Foreigncurrency;
import com.ruoyi.web.foreigncurrency.service.IForeigncurrencyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 币种名称Controller
 * 
 * @author czr
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/foreigncurrency/foreigncurrency")
public class ForeigncurrencyController extends BaseController
{
    @Autowired
    private IForeigncurrencyService foreigncurrencyService;

    /**
     * 查询币种名称列表
     */
    @PreAuthorize("@ss.hasPermi('foreigncurrency:foreigncurrency:list')")
    @GetMapping("/list")
    public TableDataInfo list(Foreigncurrency foreigncurrency)
    {
        startPage();
        List<Foreigncurrency> list = foreigncurrencyService.selectForeigncurrencyList(foreigncurrency);
        return getDataTable(list);
    }

    /**
     * 导出币种名称列表
     */
    @PreAuthorize("@ss.hasPermi('foreigncurrency:foreigncurrency:export')")
    @Log(title = "币种名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Foreigncurrency foreigncurrency)
    {
        List<Foreigncurrency> list = foreigncurrencyService.selectForeigncurrencyList(foreigncurrency);
        ExcelUtil<Foreigncurrency> util = new ExcelUtil<Foreigncurrency>(Foreigncurrency.class);
        util.exportExcel(response, list, "币种名称数据");
    }

    /**
     * 获取币种名称详细信息
     */
    @PreAuthorize("@ss.hasPermi('foreigncurrency:foreigncurrency:query')")
    @GetMapping(value = "/{iId}")
    public AjaxResult getInfo(@PathVariable("iId") Long iId)
    {
        return success(foreigncurrencyService.selectForeigncurrencyByIId(iId));
    }

    /**
     * 新增币种名称
     */
    @PreAuthorize("@ss.hasPermi('foreigncurrency:foreigncurrency:add')")
    @Log(title = "币种名称", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Foreigncurrency foreigncurrency)
    {
        return toAjax(foreigncurrencyService.insertForeigncurrency(foreigncurrency));
    }

    /**
     * 修改币种名称
     */
    @PreAuthorize("@ss.hasPermi('foreigncurrency:foreigncurrency:edit')")
    @Log(title = "币种名称", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Foreigncurrency foreigncurrency)
    {
        return toAjax(foreigncurrencyService.updateForeigncurrency(foreigncurrency));
    }

    /**
     * 删除币种名称
     */
    @PreAuthorize("@ss.hasPermi('foreigncurrency:foreigncurrency:remove')")
    @Log(title = "币种名称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iIds}")
    public AjaxResult remove(@PathVariable Long[] iIds)
    {
        return toAjax(foreigncurrencyService.deleteForeigncurrencyByIIds(iIds));
    }
}
